package com.iscas.green.extralindextest.service;

import com.iscas.green.extralindextest.client.ServiceFeignClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 服务API服务类
 */
@Service
public class ServiceApiService {

    private static final Logger log = LoggerFactory.getLogger(ServiceApiService.class);
    
    @Autowired
    private ServiceFeignClient serviceFeignClient;
    
    /**
     * 获取服务列表
     *
     * @param applicationId 应用ID
     * @param namespace 命名空间
     * @return 服务列表，如果请求失败则返回null
     */
    public Object getServiceList(String applicationId, String namespace) {
        try {
            log.info("开始调用远程服务接口获取服务列表, applicationId={}, namespace={}", applicationId, namespace);
            Object response = serviceFeignClient.getServiceList(applicationId, namespace);
            
            log.info("成功获取服务列表");
            return response;
        } catch (Exception e) {
            log.error("调用服务列表接口异常", e);
            return null;
        }
    }
} 